<?php
class ProfilefieldsController extends AppController{
    var $name='Profilefields';
    var $paginate=array(
        'limit' => '10',
        'order' => array('Profilefield.order' => 'ASC'),
    );
    function beforeFilter() {
        parent::beforeFilter();
        //$this->Auth->allow();
        $this->Auth->loginRedirect = array('controller' => 'Dashboard', 'action' => 'index');
    }
    function admin_add(){
        if(!empty($this->data)){
            $total = $this->Profilefield->find('count');
            $this->data['Profilefield']['order']=$total+1;
            if($this->Profilefield->save($this->data)){
                $this->Session->setFlash('Prpfile Field Saved');
                $this->redirect(array('controller'=>'Profilefields','action'=>'admin_index'));
            }
        }
        
    }
    function admin_edit($id=null){
        if(empty($this->data)){
            $this->data=$this->Profilefield->read(null,$id);
        }else{
            $this->Profilefield->id=$this->data['Profilefield']['id'];
            if($this->Profilefield->save($this->data)){
                $this->Session->setFlash('Field Updated');
                $this->redirect(array('controller'=>'Profilefields','action'=>'admin_index'));
            }
        }
    }
    function admin_index(){
        
        $data=$this->Paginate('Profilefield');
        $this->set('fields',$data);
        
    }
    function admin_delete($id){
        if($id){
            if($this->Profilefield->delete($id)){
                $this->Session->setFlash('Field Deleted');
                $this->redirect(array('controller'=>'Profilefields','action'=>'admin_index'));
            }
        }
    }
}
?>